package Count;

import java.util.HashSet;

public class count2 {
    //统计只出现一次的的数字
    public static void SingleNum(int[] nums){
        HashSet<Integer> set=new HashSet<>();
        for(int i=0;i< nums.length;i++){
            if(set.contains(nums[i])){
                set.remove(nums[i]);//去重
            }else{
                set.add(nums[i]);
            }
        }
        System.out.println("只出现一次的数字为：");
        for(int i=0;i< nums.length;i++){
            if(set.contains(nums[i])){
                System.out.print(nums[i]+" ");
            }
        }
    }
    public static void main(String[]args){
        int[]nums={1,1,3,5,5,7,4,9,9};
        SingleNum(nums);
    }
}
